﻿
#region Using directives

using System;
using System.Collections;
using System.Collections.Specialized;


using System.Web.Configuration;
using System.Data;
using System.Data.Common;
using System.Configuration.Provider;

using Microsoft.Practices.EnterpriseLibrary.Data;

using BesAsm.ModelData.Entities;
using BesAsm.ModelData.Data;
using BesAsm.ModelData.Data.Bases;

#endregion

namespace BesAsm.ModelData.Data.GenericClient
{
	/// <summary>
	/// This class is the Sql implementation of the NetTiersProvider.
	/// </summary>
	public sealed class GenericNetTiersProvider : BesAsm.ModelData.Data.Bases.NetTiersProvider
	{
		private static object syncRoot = new Object();
		private string _applicationName;
        private string _connectionString;
        private bool _useStoredProcedure;
        string _providerInvariantName;
		
		/// <summary>
		/// Initializes a new instance of the <see cref="GenericNetTiersProvider"/> class.
		///</summary>
		public GenericNetTiersProvider()
		{	
		}		
		
		/// <summary>
        /// Initializes the provider.
        /// </summary>
        /// <param name="name">The friendly name of the provider.</param>
        /// <param name="config">A collection of the name/value pairs representing the provider-specific attributes specified in the configuration for this provider.</param>
        /// <exception cref="T:System.ArgumentNullException">The name of the provider is null.</exception>
        /// <exception cref="T:System.InvalidOperationException">An attempt is made to call <see cref="M:System.Configuration.Provider.ProviderBase.Initialize(System.String,System.Collections.Specialized.NameValueCollection)"></see> on a provider after the provider has already been initialized.</exception>
        /// <exception cref="T:System.ArgumentException">The name of the provider has a length of zero.</exception>
		public override void Initialize(string name, NameValueCollection config)
        {
            // Verify that config isn't null
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            // Assign the provider a default name if it doesn't have one
            if (String.IsNullOrEmpty(name))
            {
                name = "SqlNetTiersProvider";
            }

            // Add a default "description" attribute to config if the
            // attribute doesn't exist or is empty
            if (string.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "NetTiers Sql provider");
            }

            // Call the base class's Initialize method
            base.Initialize(name, config);

            // Initialize _applicationName
            _applicationName = config["applicationName"];

            if (string.IsNullOrEmpty(_applicationName))
            {
                _applicationName = "/";
            }
            config.Remove("applicationName");


            #region "Initialize UseStoredProcedure"
            string storedProcedure  = config["useStoredProcedure"];
           	if (string.IsNullOrEmpty(storedProcedure))
            {
                throw new ProviderException("Empty or missing useStoredProcedure");
            }
            this._useStoredProcedure = Convert.ToBoolean(config["useStoredProcedure"]);
            config.Remove("useStoredProcedure");
            #endregion

			#region ConnectionString

			// Initialize _connectionString
			_connectionString = config["connectionString"];
			config.Remove("connectionString");

			string connect = config["connectionStringName"];
			config.Remove("connectionStringName");

			if ( String.IsNullOrEmpty(_connectionString) )
			{
				if ( String.IsNullOrEmpty(connect) )
				{
					throw new ProviderException("Empty or missing connectionStringName");
				}

				if ( DataRepository.ConnectionStrings[connect] == null )
				{
					throw new ProviderException("Missing connection string");
				}

				_connectionString = DataRepository.ConnectionStrings[connect].ConnectionString;
			}

            if ( String.IsNullOrEmpty(_connectionString) )
            {
                throw new ProviderException("Empty connection string");
			}

			#endregion
            
             #region "_providerInvariantName"

            // initialize _providerInvariantName
            this._providerInvariantName = config["providerInvariantName"];

            if (String.IsNullOrEmpty(_providerInvariantName))
            {
                throw new ProviderException("Empty or missing providerInvariantName");
            }
            config.Remove("providerInvariantName");

            #endregion

        }
		
		/// <summary>
		/// Creates a new <see cref="TransactionManager"/> instance from the current datasource.
		/// </summary>
		/// <returns></returns>
		public override TransactionManager CreateTransaction()
		{
			return new TransactionManager(this._connectionString, _providerInvariantName);
		}
		
		/// <summary>
		/// Gets a value indicating whether to use stored procedure or not.
		/// </summary>
		/// <value>
		/// 	<c>true</c> if this repository use stored procedures; otherwise, <c>false</c>.
		/// </value>
		public bool UseStoredProcedure
		{
			get {return this._useStoredProcedure;}
			set {this._useStoredProcedure = value;}
		}
		
		 /// <summary>
        /// Gets or sets the connection string.
        /// </summary>
        /// <value>The connection string.</value>
		public string ConnectionString
		{
			get {return this._connectionString;}
			set {this._connectionString = value;}
		}
		
		/// <summary>
	    /// Gets or sets the invariant provider name listed in the DbProviderFactories machine.config section.
	    /// </summary>
	    /// <value>The name of the provider invariant.</value>
	    public string ProviderInvariantName
	    {
	        get { return this._providerInvariantName; }
	        set { this._providerInvariantName = value; }
	    }		
		
		///<summary>
		/// Indicates if the current <see cref="NetTiersProvider"/> implementation supports Transacton.
		///</summary>
		public override bool IsTransactionSupported
		{
			get
			{
				return true;
			}
		}

		
		#region "ModelSscProvider"
			
		private GenericModelSscProvider _innerGenericModelSscProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="ModelSsc"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override ModelSscProviderBase ModelSscProvider
		{
			get
			{
				if (this._innerGenericModelSscProvider == null) 
				{
					lock (syncRoot) 
					{
						if (this._innerGenericModelSscProvider == null)
						{
							this._innerGenericModelSscProvider = new GenericModelSscProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return this._innerGenericModelSscProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="GenericModelSscProvider"/>.
		/// </summary>
		/// <value></value>
		public GenericModelSscProvider GenericModelSscProvider
		{
			get {return ModelSscProvider as GenericModelSscProvider;}
		}
		
		#endregion
		
		
		#region "ModelIcNodeRedirectorProvider"
			
		private GenericModelIcNodeRedirectorProvider _innerGenericModelIcNodeRedirectorProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="ModelIcNodeRedirector"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override ModelIcNodeRedirectorProviderBase ModelIcNodeRedirectorProvider
		{
			get
			{
				if (this._innerGenericModelIcNodeRedirectorProvider == null) 
				{
					lock (syncRoot) 
					{
						if (this._innerGenericModelIcNodeRedirectorProvider == null)
						{
							this._innerGenericModelIcNodeRedirectorProvider = new GenericModelIcNodeRedirectorProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return this._innerGenericModelIcNodeRedirectorProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="GenericModelIcNodeRedirectorProvider"/>.
		/// </summary>
		/// <value></value>
		public GenericModelIcNodeRedirectorProvider GenericModelIcNodeRedirectorProvider
		{
			get {return ModelIcNodeRedirectorProvider as GenericModelIcNodeRedirectorProvider;}
		}
		
		#endregion
		
		
		#region "ModelParkingTargetProvider"
			
		private GenericModelParkingTargetProvider _innerGenericModelParkingTargetProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="ModelParkingTarget"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override ModelParkingTargetProviderBase ModelParkingTargetProvider
		{
			get
			{
				if (this._innerGenericModelParkingTargetProvider == null) 
				{
					lock (syncRoot) 
					{
						if (this._innerGenericModelParkingTargetProvider == null)
						{
							this._innerGenericModelParkingTargetProvider = new GenericModelParkingTargetProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return this._innerGenericModelParkingTargetProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="GenericModelParkingTargetProvider"/>.
		/// </summary>
		/// <value></value>
		public GenericModelParkingTargetProvider GenericModelParkingTargetProvider
		{
			get {return ModelParkingTargetProvider as GenericModelParkingTargetProvider;}
		}
		
		#endregion
		
		
		#region "ModelLinkProvider"
			
		private GenericModelLinkProvider _innerGenericModelLinkProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="ModelLink"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override ModelLinkProviderBase ModelLinkProvider
		{
			get
			{
				if (this._innerGenericModelLinkProvider == null) 
				{
					lock (syncRoot) 
					{
						if (this._innerGenericModelLinkProvider == null)
						{
							this._innerGenericModelLinkProvider = new GenericModelLinkProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return this._innerGenericModelLinkProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="GenericModelLinkProvider"/>.
		/// </summary>
		/// <value></value>
		public GenericModelLinkProvider GenericModelLinkProvider
		{
			get {return ModelLinkProvider as GenericModelLinkProvider;}
		}
		
		#endregion
		
		
		#region "ModelSanPatternProvider"
			
		private GenericModelSanPatternProvider _innerGenericModelSanPatternProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="ModelSanPattern"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override ModelSanPatternProviderBase ModelSanPatternProvider
		{
			get
			{
				if (this._innerGenericModelSanPatternProvider == null) 
				{
					lock (syncRoot) 
					{
						if (this._innerGenericModelSanPatternProvider == null)
						{
							this._innerGenericModelSanPatternProvider = new GenericModelSanPatternProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return this._innerGenericModelSanPatternProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="GenericModelSanPatternProvider"/>.
		/// </summary>
		/// <value></value>
		public GenericModelSanPatternProvider GenericModelSanPatternProvider
		{
			get {return ModelSanPatternProvider as GenericModelSanPatternProvider;}
		}
		
		#endregion
		
		
		#region "ModelDscProvider"
			
		private GenericModelDscProvider _innerGenericModelDscProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="ModelDsc"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override ModelDscProviderBase ModelDscProvider
		{
			get
			{
				if (this._innerGenericModelDscProvider == null) 
				{
					lock (syncRoot) 
					{
						if (this._innerGenericModelDscProvider == null)
						{
							this._innerGenericModelDscProvider = new GenericModelDscProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return this._innerGenericModelDscProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="GenericModelDscProvider"/>.
		/// </summary>
		/// <value></value>
		public GenericModelDscProvider GenericModelDscProvider
		{
			get {return ModelDscProvider as GenericModelDscProvider;}
		}
		
		#endregion
		
		
		#region "ModelCrossSectionProvider"
			
		private GenericModelCrossSectionProvider _innerGenericModelCrossSectionProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="ModelCrossSection"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override ModelCrossSectionProviderBase ModelCrossSectionProvider
		{
			get
			{
				if (this._innerGenericModelCrossSectionProvider == null) 
				{
					lock (syncRoot) 
					{
						if (this._innerGenericModelCrossSectionProvider == null)
						{
							this._innerGenericModelCrossSectionProvider = new GenericModelCrossSectionProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return this._innerGenericModelCrossSectionProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="GenericModelCrossSectionProvider"/>.
		/// </summary>
		/// <value></value>
		public GenericModelCrossSectionProvider GenericModelCrossSectionProvider
		{
			get {return ModelCrossSectionProvider as GenericModelCrossSectionProvider;}
		}
		
		#endregion
		
		
		#region "ModelIcDiscoProvider"
			
		private GenericModelIcDiscoProvider _innerGenericModelIcDiscoProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="ModelIcDisco"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override ModelIcDiscoProviderBase ModelIcDiscoProvider
		{
			get
			{
				if (this._innerGenericModelIcDiscoProvider == null) 
				{
					lock (syncRoot) 
					{
						if (this._innerGenericModelIcDiscoProvider == null)
						{
							this._innerGenericModelIcDiscoProvider = new GenericModelIcDiscoProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return this._innerGenericModelIcDiscoProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="GenericModelIcDiscoProvider"/>.
		/// </summary>
		/// <value></value>
		public GenericModelIcDiscoProvider GenericModelIcDiscoProvider
		{
			get {return ModelIcDiscoProvider as GenericModelIcDiscoProvider;}
		}
		
		#endregion
		
		
		#region "ModelNodeProvider"
			
		private GenericModelNodeProvider _innerGenericModelNodeProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="ModelNode"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override ModelNodeProviderBase ModelNodeProvider
		{
			get
			{
				if (this._innerGenericModelNodeProvider == null) 
				{
					lock (syncRoot) 
					{
						if (this._innerGenericModelNodeProvider == null)
						{
							this._innerGenericModelNodeProvider = new GenericModelNodeProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return this._innerGenericModelNodeProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="GenericModelNodeProvider"/>.
		/// </summary>
		/// <value></value>
		public GenericModelNodeProvider GenericModelNodeProvider
		{
			get {return ModelNodeProvider as GenericModelNodeProvider;}
		}
		
		#endregion
		
		
		#region "ModelPipeShapeProvider"
			
		private GenericModelPipeShapeProvider _innerGenericModelPipeShapeProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="ModelPipeShape"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override ModelPipeShapeProviderBase ModelPipeShapeProvider
		{
			get
			{
				if (this._innerGenericModelPipeShapeProvider == null) 
				{
					lock (syncRoot) 
					{
						if (this._innerGenericModelPipeShapeProvider == null)
						{
							this._innerGenericModelPipeShapeProvider = new GenericModelPipeShapeProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return this._innerGenericModelPipeShapeProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="GenericModelPipeShapeProvider"/>.
		/// </summary>
		/// <value></value>
		public GenericModelPipeShapeProvider GenericModelPipeShapeProvider
		{
			get {return ModelPipeShapeProvider as GenericModelPipeShapeProvider;}
		}
		
		#endregion
		
		
		#region "ModelPumpCurveProvider"
			
		private GenericModelPumpCurveProvider _innerGenericModelPumpCurveProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="ModelPumpCurve"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override ModelPumpCurveProviderBase ModelPumpCurveProvider
		{
			get
			{
				if (this._innerGenericModelPumpCurveProvider == null) 
				{
					lock (syncRoot) 
					{
						if (this._innerGenericModelPumpCurveProvider == null)
						{
							this._innerGenericModelPumpCurveProvider = new GenericModelPumpCurveProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return this._innerGenericModelPumpCurveProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="GenericModelPumpCurveProvider"/>.
		/// </summary>
		/// <value></value>
		public GenericModelPumpCurveProvider GenericModelPumpCurveProvider
		{
			get {return ModelPumpCurveProvider as GenericModelPumpCurveProvider;}
		}
		
		#endregion
		
		
		#region "ModelSpecialLinkProvider"
			
		private GenericModelSpecialLinkProvider _innerGenericModelSpecialLinkProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="ModelSpecialLink"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override ModelSpecialLinkProviderBase ModelSpecialLinkProvider
		{
			get
			{
				if (this._innerGenericModelSpecialLinkProvider == null) 
				{
					lock (syncRoot) 
					{
						if (this._innerGenericModelSpecialLinkProvider == null)
						{
							this._innerGenericModelSpecialLinkProvider = new GenericModelSpecialLinkProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return this._innerGenericModelSpecialLinkProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="GenericModelSpecialLinkProvider"/>.
		/// </summary>
		/// <value></value>
		public GenericModelSpecialLinkProvider GenericModelSpecialLinkProvider
		{
			get {return ModelSpecialLinkProvider as GenericModelSpecialLinkProvider;}
		}
		
		#endregion
		
		
		#region "ModelStreetTargetProvider"
			
		private GenericModelStreetTargetProvider _innerGenericModelStreetTargetProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="ModelStreetTarget"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override ModelStreetTargetProviderBase ModelStreetTargetProvider
		{
			get
			{
				if (this._innerGenericModelStreetTargetProvider == null) 
				{
					lock (syncRoot) 
					{
						if (this._innerGenericModelStreetTargetProvider == null)
						{
							this._innerGenericModelStreetTargetProvider = new GenericModelStreetTargetProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return this._innerGenericModelStreetTargetProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="GenericModelStreetTargetProvider"/>.
		/// </summary>
		/// <value></value>
		public GenericModelStreetTargetProvider GenericModelStreetTargetProvider
		{
			get {return ModelStreetTargetProvider as GenericModelStreetTargetProvider;}
		}
		
		#endregion
		
		
		#region "ModelSpecialLinksDatumProvider"
			
		private GenericModelSpecialLinksDatumProvider _innerGenericModelSpecialLinksDatumProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="ModelSpecialLinksDatum"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override ModelSpecialLinksDatumProviderBase ModelSpecialLinksDatumProvider
		{
			get
			{
				if (this._innerGenericModelSpecialLinksDatumProvider == null) 
				{
					lock (syncRoot) 
					{
						if (this._innerGenericModelSpecialLinksDatumProvider == null)
						{
							this._innerGenericModelSpecialLinksDatumProvider = new GenericModelSpecialLinksDatumProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return this._innerGenericModelSpecialLinksDatumProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="GenericModelSpecialLinksDatumProvider"/>.
		/// </summary>
		/// <value></value>
		public GenericModelSpecialLinksDatumProvider GenericModelSpecialLinksDatumProvider
		{
			get {return ModelSpecialLinksDatumProvider as GenericModelSpecialLinksDatumProvider;}
		}
		
		#endregion
		
		
		#region "ModelIcDrywellProvider"
			
		private GenericModelIcDrywellProvider _innerGenericModelIcDrywellProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="ModelIcDrywell"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override ModelIcDrywellProviderBase ModelIcDrywellProvider
		{
			get
			{
				if (this._innerGenericModelIcDrywellProvider == null) 
				{
					lock (syncRoot) 
					{
						if (this._innerGenericModelIcDrywellProvider == null)
						{
							this._innerGenericModelIcDrywellProvider = new GenericModelIcDrywellProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return this._innerGenericModelIcDrywellProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="GenericModelIcDrywellProvider"/>.
		/// </summary>
		/// <value></value>
		public GenericModelIcDrywellProvider GenericModelIcDrywellProvider
		{
			get {return ModelIcDrywellProvider as GenericModelIcDrywellProvider;}
		}
		
		#endregion
		
		
		#region "ModelPumpProvider"
			
		private GenericModelPumpProvider _innerGenericModelPumpProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="ModelPump"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override ModelPumpProviderBase ModelPumpProvider
		{
			get
			{
				if (this._innerGenericModelPumpProvider == null) 
				{
					lock (syncRoot) 
					{
						if (this._innerGenericModelPumpProvider == null)
						{
							this._innerGenericModelPumpProvider = new GenericModelPumpProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return this._innerGenericModelPumpProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="GenericModelPumpProvider"/>.
		/// </summary>
		/// <value></value>
		public GenericModelPumpProvider GenericModelPumpProvider
		{
			get {return ModelPumpProvider as GenericModelPumpProvider;}
		}
		
		#endregion
		
		
		#region "ModelPipeShapesDatumProvider"
			
		private GenericModelPipeShapesDatumProvider _innerGenericModelPipeShapesDatumProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="ModelPipeShapesDatum"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override ModelPipeShapesDatumProviderBase ModelPipeShapesDatumProvider
		{
			get
			{
				if (this._innerGenericModelPipeShapesDatumProvider == null) 
				{
					lock (syncRoot) 
					{
						if (this._innerGenericModelPipeShapesDatumProvider == null)
						{
							this._innerGenericModelPipeShapesDatumProvider = new GenericModelPipeShapesDatumProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return this._innerGenericModelPipeShapesDatumProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="GenericModelPipeShapesDatumProvider"/>.
		/// </summary>
		/// <value></value>
		public GenericModelPipeShapesDatumProvider GenericModelPipeShapesDatumProvider
		{
			get {return ModelPipeShapesDatumProvider as GenericModelPipeShapesDatumProvider;}
		}
		
		#endregion
		
		
		#region "ModelRoofTargetProvider"
			
		private GenericModelRoofTargetProvider _innerGenericModelRoofTargetProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="ModelRoofTarget"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override ModelRoofTargetProviderBase ModelRoofTargetProvider
		{
			get
			{
				if (this._innerGenericModelRoofTargetProvider == null) 
				{
					lock (syncRoot) 
					{
						if (this._innerGenericModelRoofTargetProvider == null)
						{
							this._innerGenericModelRoofTargetProvider = new GenericModelRoofTargetProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return this._innerGenericModelRoofTargetProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="GenericModelRoofTargetProvider"/>.
		/// </summary>
		/// <value></value>
		public GenericModelRoofTargetProvider GenericModelRoofTargetProvider
		{
			get {return ModelRoofTargetProvider as GenericModelRoofTargetProvider;}
		}
		
		#endregion
		
		
		#region "ModelCrossSectionsDatumProvider"
			
		private GenericModelCrossSectionsDatumProvider _innerGenericModelCrossSectionsDatumProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="ModelCrossSectionsDatum"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override ModelCrossSectionsDatumProviderBase ModelCrossSectionsDatumProvider
		{
			get
			{
				if (this._innerGenericModelCrossSectionsDatumProvider == null) 
				{
					lock (syncRoot) 
					{
						if (this._innerGenericModelCrossSectionsDatumProvider == null)
						{
							this._innerGenericModelCrossSectionsDatumProvider = new GenericModelCrossSectionsDatumProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return this._innerGenericModelCrossSectionsDatumProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="GenericModelCrossSectionsDatumProvider"/>.
		/// </summary>
		/// <value></value>
		public GenericModelCrossSectionsDatumProvider GenericModelCrossSectionsDatumProvider
		{
			get {return ModelCrossSectionsDatumProvider as GenericModelCrossSectionsDatumProvider;}
		}
		
		#endregion
		
		
		
		#region "General data access methods"

		#region "ExecuteNonQuery"
		/// <summary>
		/// Executes the non query.
		/// </summary>
		/// <param name="storedProcedureName">Name of the stored procedure.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <returns></returns>
		public override int ExecuteNonQuery(string storedProcedureName, params object[] parameterValues)
		{
			GenericDatabase database = new GenericDatabase(this._connectionString, DbProviderFactories.GetFactory(_providerInvariantName));
			return database.ExecuteNonQuery(storedProcedureName, parameterValues);	
		}

		/// <summary>
		/// Executes the non query.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="storedProcedureName">Name of the stored procedure.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <returns></returns>
		public override int ExecuteNonQuery(TransactionManager transactionManager, string storedProcedureName, params object[] parameterValues)
		{
			GenericDatabase database = new GenericDatabase(this._connectionString, DbProviderFactories.GetFactory(_providerInvariantName));
			return database.ExecuteNonQuery(transactionManager.TransactionObject, storedProcedureName, parameterValues);	
		}

		/// <summary>
		/// Executes the non query.
		/// </summary>
		/// <param name="commandWrapper">The command wrapper.</param>
		public override void ExecuteNonQuery(DbCommand commandWrapper)
		{
			GenericDatabase database = new GenericDatabase(this._connectionString, DbProviderFactories.GetFactory(_providerInvariantName));
			database.ExecuteNonQuery(commandWrapper);	
			
		}

		/// <summary>
		/// Executes the non query.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="commandWrapper">The command wrapper.</param>
		public override void ExecuteNonQuery(TransactionManager transactionManager, DbCommand commandWrapper)
		{
			GenericDatabase database = new GenericDatabase(this._connectionString, DbProviderFactories.GetFactory(_providerInvariantName));
			database.ExecuteNonQuery(commandWrapper, transactionManager.TransactionObject);	
		}


		/// <summary>
		/// Executes the non query.
		/// </summary>
		/// <param name="commandType">Type of the command.</param>
		/// <param name="commandText">The command text.</param>
		/// <returns></returns>
		public override int ExecuteNonQuery(CommandType commandType, string commandText)
		{
			GenericDatabase database = new GenericDatabase(this._connectionString, DbProviderFactories.GetFactory(_providerInvariantName));
			return database.ExecuteNonQuery(commandType, commandText);	
		}
		/// <summary>
		/// Executes the non query.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="commandType">Type of the command.</param>
		/// <param name="commandText">The command text.</param>
		/// <returns></returns>
		public override int ExecuteNonQuery(TransactionManager transactionManager, CommandType commandType, string commandText)
		{
			Database database = transactionManager.Database;			
			return database.ExecuteNonQuery(transactionManager.TransactionObject , commandType, commandText);				
		}
		#endregion

		#region "ExecuteDataReader"
		/// <summary>
		/// Executes the reader.
		/// </summary>
		/// <param name="storedProcedureName">Name of the stored procedure.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <returns></returns>
		public override IDataReader ExecuteReader(string storedProcedureName, params object[] parameterValues)
		{
			GenericDatabase database = new GenericDatabase(this._connectionString, DbProviderFactories.GetFactory(_providerInvariantName));	
			return database.ExecuteReader(storedProcedureName, parameterValues);	
		}

		/// <summary>
		/// Executes the reader.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="storedProcedureName">Name of the stored procedure.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <returns></returns>
		public override IDataReader ExecuteReader(TransactionManager transactionManager, string storedProcedureName, params object[] parameterValues)
		{
			Database database = transactionManager.Database;
			return database.ExecuteReader(transactionManager.TransactionObject, storedProcedureName, parameterValues);	
		}

		/// <summary>
		/// Executes the reader.
		/// </summary>
		/// <param name="commandWrapper">The command wrapper.</param>
		/// <returns></returns>
		public override IDataReader ExecuteReader(DbCommand commandWrapper)
		{
		GenericDatabase database = new GenericDatabase(this._connectionString, DbProviderFactories.GetFactory(_providerInvariantName));	
			return database.ExecuteReader(commandWrapper);	
		}

		/// <summary>
		/// Executes the reader.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="commandWrapper">The command wrapper.</param>
		/// <returns></returns>
		public override IDataReader ExecuteReader(TransactionManager transactionManager, DbCommand commandWrapper)
		{
			Database database = transactionManager.Database;
			return database.ExecuteReader(commandWrapper, transactionManager.TransactionObject);	
		}


		/// <summary>
		/// Executes the reader.
		/// </summary>
		/// <param name="commandType">Type of the command.</param>
		/// <param name="commandText">The command text.</param>
		/// <returns></returns>
		public override IDataReader ExecuteReader(CommandType commandType, string commandText)
		{
			GenericDatabase database = new GenericDatabase(this._connectionString, DbProviderFactories.GetFactory(_providerInvariantName));
			return database.ExecuteReader(commandType, commandText);	
		}
		/// <summary>
		/// Executes the reader.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="commandType">Type of the command.</param>
		/// <param name="commandText">The command text.</param>
		/// <returns></returns>
		public override IDataReader ExecuteReader(TransactionManager transactionManager, CommandType commandType, string commandText)
		{
			Database database = transactionManager.Database;			
			return database.ExecuteReader(transactionManager.TransactionObject , commandType, commandText);				
		}
		#endregion

		#region "ExecuteDataSet"
		/// <summary>
		/// Executes the data set.
		/// </summary>
		/// <param name="storedProcedureName">Name of the stored procedure.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <returns></returns>
		public override DataSet ExecuteDataSet(string storedProcedureName, params object[] parameterValues)
		{
			GenericDatabase database = new GenericDatabase(this._connectionString, DbProviderFactories.GetFactory(_providerInvariantName));	
			return database.ExecuteDataSet(storedProcedureName, parameterValues);	
		}

		/// <summary>
		/// Executes the data set.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="storedProcedureName">Name of the stored procedure.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <returns></returns>
		public override DataSet ExecuteDataSet(TransactionManager transactionManager, string storedProcedureName, params object[] parameterValues)
		{
			Database database = transactionManager.Database;
			return database.ExecuteDataSet(transactionManager.TransactionObject, storedProcedureName, parameterValues);	
		}

		/// <summary>
		/// Executes the data set.
		/// </summary>
		/// <param name="commandWrapper">The command wrapper.</param>
		/// <returns></returns>
		public override DataSet ExecuteDataSet(DbCommand commandWrapper)
		{
			GenericDatabase database = new GenericDatabase(this._connectionString, DbProviderFactories.GetFactory(_providerInvariantName));
			return database.ExecuteDataSet(commandWrapper);	
		}

		/// <summary>
		/// Executes the data set.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="commandWrapper">The command wrapper.</param>
		/// <returns></returns>
		public override DataSet ExecuteDataSet(TransactionManager transactionManager, DbCommand commandWrapper)
		{
			Database database = transactionManager.Database;
			return database.ExecuteDataSet(commandWrapper, transactionManager.TransactionObject);	
		}


		/// <summary>
		/// Executes the data set.
		/// </summary>
		/// <param name="commandType">Type of the command.</param>
		/// <param name="commandText">The command text.</param>
		/// <returns></returns>
		public override DataSet ExecuteDataSet(CommandType commandType, string commandText)
		{
			GenericDatabase database = new GenericDatabase(this._connectionString, DbProviderFactories.GetFactory(_providerInvariantName));
			return database.ExecuteDataSet(commandType, commandText);	
		}
		/// <summary>
		/// Executes the data set.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="commandType">Type of the command.</param>
		/// <param name="commandText">The command text.</param>
		/// <returns></returns>
		public override DataSet ExecuteDataSet(TransactionManager transactionManager, CommandType commandType, string commandText)
		{
			Database database = transactionManager.Database;			
			return database.ExecuteDataSet(transactionManager.TransactionObject , commandType, commandText);				
		}
		#endregion

		#region "ExecuteScalar"
		/// <summary>
		/// Executes the scalar.
		/// </summary>
		/// <param name="storedProcedureName">Name of the stored procedure.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <returns></returns>
		public override object ExecuteScalar(string storedProcedureName, params object[] parameterValues)
		{
			GenericDatabase database = new GenericDatabase(this._connectionString, DbProviderFactories.GetFactory(_providerInvariantName));		
			return database.ExecuteScalar(storedProcedureName, parameterValues);	
		}

		/// <summary>
		/// Executes the scalar.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="storedProcedureName">Name of the stored procedure.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <returns></returns>
		public override object ExecuteScalar(TransactionManager transactionManager, string storedProcedureName, params object[] parameterValues)
		{
			Database database = transactionManager.Database;
			return database.ExecuteScalar(transactionManager.TransactionObject, storedProcedureName, parameterValues);	
		}

		/// <summary>
		/// Executes the scalar.
		/// </summary>
		/// <param name="commandWrapper">The command wrapper.</param>
		/// <returns></returns>
		public override object ExecuteScalar(DbCommand commandWrapper)
		{
			GenericDatabase database = new GenericDatabase(this._connectionString, DbProviderFactories.GetFactory(_providerInvariantName));
			return database.ExecuteScalar(commandWrapper);	
		}

		/// <summary>
		/// Executes the scalar.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="commandWrapper">The command wrapper.</param>
		/// <returns></returns>
		public override object ExecuteScalar(TransactionManager transactionManager, DbCommand commandWrapper)
		{
			Database database = transactionManager.Database;
			return database.ExecuteScalar(commandWrapper, transactionManager.TransactionObject);	
		}

		/// <summary>
		/// Executes the scalar.
		/// </summary>
		/// <param name="commandType">Type of the command.</param>
		/// <param name="commandText">The command text.</param>
		/// <returns></returns>
		public override object ExecuteScalar(CommandType commandType, string commandText)
		{
			GenericDatabase database = new GenericDatabase(this._connectionString, DbProviderFactories.GetFactory(_providerInvariantName));
			return database.ExecuteScalar(commandType, commandText);	
		}
		/// <summary>
		/// Executes the scalar.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="commandType">Type of the command.</param>
		/// <param name="commandText">The command text.</param>
		/// <returns></returns>
		public override object ExecuteScalar(TransactionManager transactionManager, CommandType commandType, string commandText)
		{
			Database database = transactionManager.Database;			
			return database.ExecuteScalar(transactionManager.TransactionObject , commandType, commandText);				
		}
		#endregion

		#endregion


	}
}
